package edu.faytechcc.csc.gui;

import edu.faytechcc.csc.messages.Connection;
import java.awt.Dimension;
import javax.swing.JFrame;

/**
 * Please describe what this class does here.
 *
 * CSC 251 0001 DATE:
 *
 * @author Stephanie Mckenzie
 */
public class ClientFrame extends JFrame
{

    public ClientFrame(Connection conn)
    {
        //Close the Window when X is clicked
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //make user log in
        LogInFrame logIn = new LogInFrame(conn);
        
        //use if you want to set a specific size for this panel
        this.setPreferredSize(new Dimension(300, 300));

        //UserNameListPanel nameListPanel = new UserNameListPanel();
        //ChatPanel chatPanel = new ChatPanel();

        //this.add(nameListPanel);

        //Display the window.
        this.pack();
        this.setLocationRelativeTo(null);
        this.setVisible(true);

        //display log in
        logIn.createAndShowGUI();
        ChatWindow window = new ChatWindow(conn, logIn.getName());
        conn.addChatWindow(window);
        window.createAndShowGUI();
        
        //waiting until people log in
        while (logIn.isVisible())
        {
        }
        this.setTitle(logIn.getName());
        window.enableTextField();

        //chatPanel.setLocalUserID(logIn.getName());
    }
}
